package com.yugao.fintech.antelope.base.feign;

import com.yugao.fintech.antelope.base.feign.interceptor.FeignRequestInterceptor;
import com.yugao.fintech.antelope.base.feign.interceptor.FeignTokenRequestInterceptor;
import feign.RequestInterceptor;
import feign.codec.ErrorDecoder;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.cloud.openfeign.FeignAutoConfiguration;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
@ConditionalOnClass({ FeignAutoConfiguration.class})
public class FeignMainConfig {
    @Bean
    public RequestInterceptor feignCommonRequestInterceptor() {
        return new FeignRequestInterceptor();
    }

    @Bean
    public ErrorDecoder errorDecoder() {
        return new FeignErrorDecoder();
    }

    @Bean
    public RequestInterceptor requestInterceptor() {
        return new FeignTokenRequestInterceptor();
    }
}
